<template>
	<view>
		<view class="zctab-bar-box">
			<tab-bar style="width: 100%;" :tabBars="tabBar.tabBars" :tabIndex="tabBar.tabIndex" @tapTab="tapTab"></tab-bar>
			<view class="uni-tab-bar">
				<view class="swiper-box" >
					<view class="zc-tab-bar" :key="0" v-show="tabBar.tabIndex === 0">
						<view class="zcSearch">
							<view class="input-view zcRelative">
								<uni-icon class='uni-icon' type="search" size="22" color="#3CA4FA" />
								<input confirm-type="search" class="input" type="text" @blur="(even)=>zcSearchInput('算价',even)" placeholder="输入搜索车牌/车主姓名" />
							</view>
						</view>
						
						<!-- 订单 -- 算价 -->
                        <view class="refreshBox">
                            <view class="refresh_item" style="height: 50px;" :style="{'transform':'translateY('+groupTop1+'px)','transition':isTransfrom?'transform .3s':''}">
                                <view class="iconfont icon-shuaxin" :style="{'transform':'rotate('+ refreshIconDeg +'deg)'}"></view>
                                <view>{{refreshText}}</view>
                            </view>
                            <scroll-view class="list" scroll-y @scrolltolower="loadMore1"
                            @scrolltoupper="toupper"
                            id="scroll" 
                            @touchend="zcTouchend"
                            @touchstart="zcTouchstart" 
                            @touchmove.stop="zcTouchmove" :style="{'transform':'translateY('+groupTop+'px)','transition':isTransfrom?'transform .3s':''}">
                                <orderList :InsurePolicy='InsurePolicy' @doOrderDetail="doCountPriceInfo()"></orderList>
                                <view v-show="tabBar.loadingText" class="uni-tab-bar-loading">
                                    {{tabBar.loadingText}}
                                </view>
                                <view v-if="InsurePolicy.length <1 && isPriceShow" class="uni-tab-bar-loading" style="text-align: center;">
                                    <view class="no_model">
                                        <image :src="imgPath+'UniImages/no_data.png'" mode="widthFix" style="width: 100%;"></image>
                                        <view class="no_text">暂无数据</view>
                                    </view>
                                </view>
                            </scroll-view>
                        </view>
					</view>
					<view class="zc-tab-bar" :key="1" v-show="tabBar.tabIndex === 1">
						<view class="zcSearch">
							<view class="input-view zcRelative">
								<uni-icon class='uni-icon' type="search" size="22" color="#3CA4FA" />
								<input confirm-type="search" class="input" type="text" @blur="(even)=>zcSearchInput('核保中',even)" placeholder="输入搜索车牌/车主姓名" />
							</view>
						</view>
                        
                        <!-- 订单 -- 核保 -->
                        <view class="refreshBox">
                            <view class="refresh_item" style="height: 50px;" :style="{'transform':'translateY('+groupTop1+'px)','transition':isTransfrom?'transform .3s':''}">
                                <view class="iconfont icon-shuaxin" :style="{'transform':'rotate('+ refreshIconDeg +'deg)'}"></view>
                                <view>{{refreshText}}</view>
                            </view>
                            <scroll-view class="list" scroll-y @scrolltolower="loadMore2"
                            @scrolltoupper="toupper"
                            id="scroll2" 
                            @touchend="zcTouchend"
                            @touchstart="zcTouchstart" 
                            @touchmove.stop="zcTouchmove" :style="{'transform':'translateY('+groupTop+'px)','transition':isTransfrom?'transform .3s':''}">
                            	<orderList :InsurePolicy='InsurePolicy'></orderList>
                            	<view v-show="tabBar.loadingText" class="uni-tab-bar-loading">
                            		{{tabBar.loadingText}}
                            	</view>
                            	<view v-if="InsurePolicy.length <1 && isUnderwritShow" class="uni-tab-bar-loading" style="text-align: center;">
                            		<view class="no_model">
                            			<image :src="imgPath+'UniImages/no_data.png'" mode="widthFix" style="width: 100%;"></image>
                            			<view class="no_text">暂无数据</view>
                            		</view>
                            	</view>
                            </scroll-view>
                        </view>
                        
					</view>
					<view class="zc-tab-bar" :key="2" v-show="tabBar.tabIndex === 2">
						<view class="zcSearch">
							<view class="input-view zcRelative">
								<uni-icon class='uni-icon' type="search" size="22" color="#3CA4FA" />
								<input confirm-type="search" class="input" type="text" @blur="(even)=>zcSearchInput('待修改',even)" placeholder="输入搜索车牌/车主姓名" />
							</view>
						</view>
                        <!-- 订单 -- 待修改 -->
						<view class="refreshBox">
                            <view class="refresh_item" style="height: 50px;" :style="{'transform':'translateY('+groupTop1+'px)','transition':isTransfrom?'transform .3s':''}">
                                <view class="iconfont icon-shuaxin" :style="{'transform':'rotate('+ refreshIconDeg +'deg)'}"></view>
                                <view>{{refreshText}}</view>
                            </view>
                            <scroll-view class="list" scroll-y @scrolltolower="loadMore3"
                            @scrolltoupper="toupper"
                            id="scroll3" 
                            @touchend="zcTouchend"
                            @touchstart="zcTouchstart" 
                            @touchmove.stop="zcTouchmove" :style="{'transform':'translateY('+groupTop+'px)','transition':isTransfrom?'transform .3s':''}">
                            	<orderList :InsurePolicy='InsurePolicy' isModify=true isAlter=true @doOrderDetail="doModifyInfo(0,$event)"></orderList>
                            
                            	<view v-show="tabBar.loadingText" class="uni-tab-bar-loading">
                            		{{tabBar.loadingText}}
                            	</view>
                            	<view v-if="InsurePolicy.length <1 && isModifyShow" class="uni-tab-bar-loading" style="text-align: center;">
                            		<view class="no_model">
                            			<image :src="imgPath+'UniImages/no_data.png'" mode="widthFix" style="width: 100%;"></image>
                            			<view class="no_text">暂无数据</view>
                            		</view>
                            	</view>
                            </scroll-view>
                        </view>
					</view>
					<view class="zc-tab-bar" :key="3" v-show="tabBar.tabIndex === 3">
						<view class="zcSearch">
							<view class="input-view zcRelative">
								<uni-icon class='uni-icon' type="search" size="22" color="#3CA4FA" />
								<input confirm-type="search" class="input" type="text" @blur="(even)=>zcSearchInput('待支付',even)" placeholder="输入搜索车牌/车主姓名" />
							</view>
						</view>
                        <!-- 订单 -- 待支付 -->
						<view class="refreshBox">
                            <view class="refresh_item" style="height: 50px;" :style="{'transform':'translateY('+groupTop1+'px)','transition':isTransfrom?'transform .3s':''}">
                                <view class="iconfont icon-shuaxin" :style="{'transform':'rotate('+ refreshIconDeg +'deg)'}"></view>
                                <view>{{refreshText}}</view>
                            </view>
                            <scroll-view class="list" scroll-y @scrolltolower="loadMore4"
                            @scrolltoupper="toupper"
                            id="scroll4" 
                            @touchend="zcTouchend"
                            @touchstart="zcTouchstart" 
                            @touchmove.stop="zcTouchmove" :style="{'transform':'translateY('+groupTop+'px)','transition':isTransfrom?'transform .3s':''}">
                            	<orderList :InsurePolicy='InsurePolicy' @doOrderDetail="doModifyInfo(1,$event)"></orderList>
                            	<view v-show="tabBar.loadingText" class="uni-tab-bar-loading">
                            		{{tabBar.loadingText}}
                            	</view>
                            	<view v-if="InsurePolicy.length <1 && isPaymentShow" class="uni-tab-bar-loading" style="text-align: center;">
                            		<view class="no_model">
                            			<image :src="imgPath+'UniImages/no_data.png'" mode="widthFix" style="width: 100%;"></image>
                            			<view class="no_text">暂无数据</view>
                            		</view>
                            	</view>
                            </scroll-view>
                        </view>
					</view>
					<view class="zc-tab-bar" :key="4" v-show="tabBar.tabIndex === 4">
						<view class="zcSearch">
							<view class="input-view zcRelative">
								<uni-icon class='uni-icon' type="search" size="22" color="#3CA4FA" />
								<input confirm-type="search" class="input" type="text" @blur="(even)=>zcSearchInput('已完成',even)" placeholder="输入搜索车牌/车主姓名" />
							</view>
						</view>
                        
                        <!-- 订单 -- 已完成 -->
						<view class="refreshBox">
                            <view class="refresh_item" style="height: 50px;" :style="{'transform':'translateY('+groupTop1+'px)','transition':isTransfrom?'transform .3s':''}">
                                <view class="iconfont icon-shuaxin" :style="{'transform':'rotate('+ refreshIconDeg +'deg)'}"></view>
                                <view>{{refreshText}}</view>
                            </view>
                            <scroll-view class="list" scroll-y @scrolltolower="loadMore5"
                            @scrolltoupper="toupper"
                            id="scroll5" 
                            @touchend="zcTouchend"
                            @touchstart="zcTouchstart" 
                            @touchmove.stop="zcTouchmove" :style="{'transform':'translateY('+groupTop+'px)','transition':isTransfrom?'transform .3s':''}">
                            	<orderList :InsurePolicy='InsurePolicy' @doOrderDetail="doCompleteInfo"></orderList>
                            	<view v-show="tabBar.loadingText" class="uni-tab-bar-loading">
                            		{{tabBar.loadingText}}
                            	</view>
                            	<view v-if="InsurePolicy.length <1 && isCompleteShow" class="uni-tab-bar-loading" style="text-align: center;">
                            		<view class="no_model">
                            			<image :src="imgPath+'UniImages/no_data.png'" mode="widthFix" style="width: 100%;"></image>
                            			<view class="no_text">暂无数据</view>
                            		</view>
                            	</view>
                            </scroll-view>
                        </view>
					</view>
				</view>
			</view>
		</view>
        
        
        <view class="insureVerifyBox" v-show="verifyBox.isShow">
            <view class="insureVerifyMask"></view>
            <view class="insureVerifyContent">
                <view class="uni-flex zcAlignI_center zcJustifyC_center insureVerifyHeader">
                	<view class="uni-flex zcAlignI_center" style="width:75upx;margin-right: 8px;">
                		<image :src="verifyBox.data.InsureCompanyLogo.LUrl" mode="widthFix"  style="height: 38upx;"></image>
                	</view>
                	<view>{{verifyBox.data.InsureCompany}}</view>
                </view>
                <view class="uni-flex zcAlignI_center insureVerifyCode" v-if="verifyBox.trafficUrl">
                	<view class="uni-flex zcAlignI_center" style="width:120upx;margin-right: 8px;">
                		<image :src="verifyBox.trafficUrl" mode="widthFix" ></image>
                	</view>
                	<view class='insureCompany'><input type="text" value="" placeholder="请输入交强险验证码" @input="(res)=>zcVerifyInputChange(1,res)" /></view>
                </view>
                <view class="uni-flex zcAlignI_center insureVerifyCode" v-if="verifyBox.bizUrl">
                	<view class="uni-flex zcAlignI_center" style="width:120upx;margin-right: 8px;">
                		<image :src="verifyBox.bizUrl" mode="widthFix" ></image>
                	</view>
                	<view class='insureCompany'><input type="text" value="" placeholder="请输入商业险验证码" @input="(res)=>zcVerifyInputChange(2,res)" /></view>
                </view>
                <view class="uni-flex zcAlignI_center insureVerifyCode">
                	<button size="mini" @tap="InsureVerifyFn('cancel')">取消</button>
                    <button size="mini" @tap="InsureVerifyFn('confirm')">提交</button>
                </view>
            </view>
        </view>
        
	</view>
</template>

<script>
	import tabBar from "../../components/tab-bar/tab-bar.vue"
	import uniIcon from "../../components/uni-icon/uni-icon.vue"
	import orderList from "../../components/zc-order-list/zc-order-list.vue"
	
	let _this;
    let startY;
    let scrollTop;
    let time;   // 处理刷新图标动画时间
    let pageTop = 0;
    let groupIsTop = false;
    let scrollToplength = 0;  // scroll-view 到顶部的距离
    let startToplength = 0;  // scroll-view 到顶部的距离
    let isDropRefresh = false;    // 是否开启下拉刷新
    
	export default {
		components:{
			tabBar,
			uniIcon,
			orderList
		},
		data() {
			return {
				imgPath:this.$ZcPublic.Domain,
				isNoDataShow:false,
				searchText:'',	// 搜索内容
				pages:20,	// 每页 显示多少条数据
				pageIndex:0,	// 当前数据开始数据是第几条
				dataLength:0,	// 当前数据返回个数
				tabBar:{
					tabIndex:0,
					loadingText:'',
					tabBars:[
						{
							name:'算价'
						},
						{
							name:'核保中'
						},
						{
							name:'待修改'
						},
						{
							name:'待支付'
						},
						{
							name:'完成'
						}
					],
					
				},
				isPriceShow:false,
				prices:[
					// {CustomerName:'中山',VehiclePlateNo:'川Q0001',InsureCompany:'平安',InsureMoney:'4000'}
				],	//算价
				isUnderwritShow:false,
				underwritings:[],	//核保中
				isModifyShow:false,
				modifys:[],	//待修改
				isPaymentShow:false,
				payments:[],	//待支付
				isCompleteShow:false,
				completes:[],	//完成
				/* 2019-10-28唐梓元修改 */
				InsurePolicy:[],
				linkSearchs:[],	// 模糊查找 数据源
				isLoading:true,
                verifyBox:{
                    isShow:false,
                    data:{},
                    bizUrl:'',
                    bizValue:'',
                    trafficUrl:'',
                    trafficValue:''
                },
                groupTop:0, // 下拉刷新 拉离顶部距离
                groupTop1:-50, // 下拉刷新 拉离顶部距离
                refreshIconDeg:0,
                refreshText:'下拉刷新',
                isTransfrom:false,
			}
		},
		onLoad(res) {
			_this = this;
			uni.showLoading({
				title: '加载中',
				mask: true
			});
			if (res.tabIndex) {
				_this.pageIndex = 0;	// 当前数据开始数据是第几条
				_this.dataLength = 0;	// 当前数据返回个数
				_this.tabBar.loadingText = '';
				_this.InsurePolicy = [];
				_this.linkSearchs = [];
				
				_this.tapTab(parseInt(res.tabIndex));
				
			}else {
				_this.zcQueryInsureOrderList('算价');
			}
			
		},
        onReady() {
            uni.createSelectorQuery().select('#scroll').boundingClientRect(function (res) {
                // 获取列表初始化窗口距离顶部长度（固定值，每次初始化赋值）
                scrollToplength = res.top;
            }).exec();
        },
		onTabItemTap(res) {
			if (res.text === '订单') {
				if (this.isLoading && this.tabBar.tabIndex !== 0) {
					this.isLoading = false;
					_this.tapTab(0);
				}
			}
		},
		methods: {
            toupper(res) {
                _this.groupTop = 0;
                _this.groupTop1 = -50;
            },
            zcTouchstart(res) {
                
                startY = res.touches[0].pageY;
                if (_this.tabBar.tabIndex === 0) {
                   uni.createSelectorQuery().select('#scroll').boundingClientRect(function (res) {
                       startToplength = res.top;
                       _this.isTransfrom = false;
                       if (res.top == scrollToplength) {
                           isDropRefresh = true;
                       }else {
                           isDropRefresh = false;
                       }
                   }).exec(); 
                }else if (_this.tabBar.tabIndex === 1) {
                    uni.createSelectorQuery().select('#scroll2').boundingClientRect(function (res) {
                        startToplength = res.top;
                        _this.isTransfrom = false;
                        if (res.top == scrollToplength) {
                            isDropRefresh = true;
                        }else {
                            isDropRefresh = false;
                        }
                    }).exec();
                }else if (_this.tabBar.tabIndex === 2) {
                    uni.createSelectorQuery().select('#scroll3').boundingClientRect(function (res) {
                        startToplength = res.top;
                        _this.isTransfrom = false;
                        if (res.top == scrollToplength) {
                            isDropRefresh = true;
                        }else {
                            isDropRefresh = false;
                        }
                    }).exec();
                }else if (_this.tabBar.tabIndex === 3) {
                    uni.createSelectorQuery().select('#scroll4').boundingClientRect(function (res) {
                        startToplength = res.top;
                        _this.isTransfrom = false;
                        if (res.top == scrollToplength) {
                            isDropRefresh = true;
                        }else {
                            isDropRefresh = false;
                        }
                    }).exec();
                }else if (_this.tabBar.tabIndex === 4) {
                    uni.createSelectorQuery().select('#scroll5').boundingClientRect(function (res) {
                        startToplength = res.top;
                        _this.isTransfrom = false;
                        if (res.top == scrollToplength) {
                            isDropRefresh = true;
                        }else {
                            isDropRefresh = false;
                        }
                    }).exec();
                }
                
            },
            zcTouchend(res) {
                if (_this.groupTop > 50) {
                    _this.groupTop = 50;
                    _this.groupTop1 = 0;
                    _this.refreshText = '刷新中'
                    _this.isTransfrom = true;
                    time = setInterval(function(){
                        _this.refreshIconDeg = _this.refreshIconDeg+45;
                    },100)
                    
                    setTimeout(function() {
                        _this.pageIndex = 0;	// 当前数据开始数据是第几条
                        _this.dataLength = 0;	// 当前数据返回个数
                        _this.tabBar.loadingText = '';
                        _this.InsurePolicy = [];
                        _this.linkSearchs = [];
                        
                        if (_this.tabBar.tabIndex === 0) {
                        	_this.zcQueryInsureOrderList('算价');
                        }else if (_this.tabBar.tabIndex === 1) {
                        	_this.zcQueryInsureOrderList('核保中');
                        }else if (_this.tabBar.tabIndex === 2) {
                        	_this.zcQueryInsureOrderList('待修改');
                        }else if (_this.tabBar.tabIndex === 3) {
                        	_this.zcQueryInsureOrderList('待支付');
                        }else if (_this.tabBar.tabIndex === 4) {
                        	_this.zcQueryInsurePolicy4SalesMan();
                        }
                    }, 1000);
                }else if (_this.groupTop < 50) {
                    _this.groupTop = 0;
                    _this.groupTop1 = -50;
                    _this.refreshText = '下拉刷新';
                    _this.isTransfrom = true;
                }
            },
            zcTouchmove(res) {
                //  判断列表是否到顶，未到顶则不做处理
                if (!isDropRefresh) {
                    return;
                }
                scrollTop = (res.touches[0].pageY - startY)*0.5;
                if (scrollTop > 0) {
                    //  判断是否是页面初始化时就触发下拉刷新 （pageTop == 0 ：表示当前是页面初始化触发的下拉刷新）
                    if (pageTop == 0) {
                        pageTop = scrollTop;
                        groupIsTop = true;
                    }
                    _this.groupTop = scrollTop - pageTop;
                    _this.groupTop1 = _this.groupTop-50;
                    if (_this.groupTop > 50) {
                        _this.refreshText = '松开刷新'
                    }else if (_this.groupTop < 50 ) {
                        _this.refreshText = '下拉刷新'
                    }
                }
                
            },
			zcSearchInput(type,res) {
				
				_this.pageIndex = 0;
				_this.InsurePolicy = [];
				_this.searchText = res.detail.value;
                if (type == '已完成') {
                    _this.zcQueryInsurePolicy4SalesMan();
                }else {
                    _this.zcQueryInsureOrderList(type);
                }
			},
			confirm(res) {
				console.log('监听键盘搜索按钮',res.detail.value);
			},
			tapTab(res) {
				_this.tabBar.tabIndex = parseInt(res);//一旦访问data就会出问题
				
				uni.showLoading({
					title: '加载中',
					mask: true
				});
				_this.pageIndex = 0;	// 当前数据开始数据是第几条
				_this.dataLength = 0;	// 当前数据返回个数
				_this.tabBar.loadingText = '';
				_this.InsurePolicy = [];
				_this.linkSearchs = [];
				
				
				if (parseInt(res) === 0) {
					_this.zcQueryInsureOrderList('算价','init');
				}else if (parseInt(res) === 1) {
					_this.zcQueryInsureOrderList('核保中','init');
				}else if (parseInt(res) === 2) {
					_this.zcQueryInsureOrderList('待修改','init');
				}else if (parseInt(res) === 3) {
					_this.zcQueryInsureOrderList('待支付','init');
				}else if (parseInt(res) === 4) {
					_this.zcQueryInsurePolicy4SalesMan('init');
				}
			},
			//  算价详情
			doCountPriceInfo(res) {
                console.log('测试 -- ',res);
                if (res.status == '已算价') {
                    uni.navigateTo({
                    	url: '../order_countPriceInfo/order_countPriceInfo?InsureOrderSN='+res.SN
                    });
                }else if (res.status == '算价验证' || res.status == '待验证') {
                    _this.verifyBox.data = res;
                    _this.zcGetInsureOrderVerifyURL(res);
                }else {
                    uni.showModal({
                        title: '温馨提示',
                        content: '尊敬的用户，请耐心等待算价成功！',
                        showCancel: false
                    });
                }
			},
			doModifyInfo(index,item) {
				uni.navigateTo({
					url: '../order_modifyInfo/order_modifyInfo?index='+index+'&InsureOrderSN='+item.SN
				});
			},
			doCompleteInfo(item) {
				uni.navigateTo({
					url: '../order_complete_info/order_complete_info?InsurePolicySN='+item.SN
				});
			},
            // 下拉刷新事件
            upperLoad() {
                uni.showLoading({
                	title: '加载中',
                	mask: true
                });
                _this.pageIndex = 0;	// 当前数据开始数据是第几条
                _this.dataLength = 0;	// 当前数据返回个数
                _this.tabBar.loadingText = '';
                _this.InsurePolicy = [];
                _this.linkSearchs = [];
                
                if (_this.tabBar.tabIndex === 0) {
                	_this.zcQueryInsureOrderList('算价');
                }else if (_this.tabBar.tabIndex === 1) {
                	_this.zcQueryInsureOrderList('核保中');
                }else if (_this.tabBar.tabIndex === 2) {
                	_this.zcQueryInsureOrderList('待修改');
                }else if (_this.tabBar.tabIndex === 3) {
                	_this.zcQueryInsureOrderList('待支付');
                }else if (_this.tabBar.tabIndex === 4) {
                	_this.zcQueryInsurePolicy4SalesMan();
                }
            },
			loadMore1() {
				if (_this.dataLength<_this.pages) {
					return;
				}
				_this.tabBar.loadingText = '加载中';
				_this.zcQueryInsureOrderList('算价');
			},
			loadMore2() {
				if (_this.dataLength<_this.pages) {
					return;
				}
				_this.tabBar.loadingText = '加载中';
				_this.zcQueryInsureOrderList('核保中');
			},
			loadMore3() {
				if (_this.dataLength<_this.pages) {
					return;
				}
				_this.tabBar.loadingText = '加载中';
				_this.zcQueryInsureOrderList('待修改');
			},
			loadMore4() {
				if (_this.dataLength<_this.pages) {
					return;
				}
				_this.tabBar.loadingText = '加载中';
				_this.zcQueryInsureOrderList('待支付');
			},
			loadMore5() {
				if (_this.dataLength<_this.pages) {
					return;
				}
				_this.tabBar.loadingText = '加载中';
				_this.zcQueryInsurePolicy4SalesMan();
			},
			
			
			//  ---------  接口区 ------------
			zcQueryInsureOrderList(status,type) {	// 订单列表接口 适用于不同状态  （算价, 核保中, 待修改, 待支付, 完成）
				_this.$ZcPublic.Server.Post({
					IsNeedLogin: true,
					Paras: {
						Name: 'uni_Insure_Detail',
						Action: 'Ext_QueryInsureOrderList',
						Data: {
							Status:status,
							data:_this.searchText,
							RowCount:_this.pages,
							StartRow:_this.pageIndex
						}
					},
					Callback:function(resjson,scope) {
						if (resjson.state === 'back') {
							if (!resjson.success) {
								uni.showModal({
									title:'温馨提示',
									showCancel:false,
									content:''+resjson.msg
								})
								return;
							}
                            if (type == 'init') {
                                if (status === '算价') {
                                	uni.createSelectorQuery().select('#scroll').boundingClientRect(function (res) {
                                	    scrollToplength = res.top;
                                	}).exec();
                                }else if (status === '核保中') {
                                	uni.createSelectorQuery().select('#scroll2').boundingClientRect(function (res) {
                                	    scrollToplength = res.top;
                                	}).exec();
                                }else if (status === '待修改') {
                                	uni.createSelectorQuery().select('#scroll3').boundingClientRect(function (res) {
                                	    scrollToplength = res.top;
                                	}).exec();
                                }else if (status === '待支付') {
                                	uni.createSelectorQuery().select('#scroll4').boundingClientRect(function (res) {
                                	    scrollToplength = res.top;
                                	}).exec();
                                }
                            }
                            
							
							_this.searchText = '';	//	初始化 搜索值
							
							if (resjson.data.length >0) {
								_this.pageIndex = _this.pageIndex+resjson.data.length;	// 初始化 下次加载开始下标
								_this.dataLength = resjson.data.length;
								if (_this.dataLength < _this.pages) {
									if (_this.pageIndex >= _this.pages) {
										_this.tabBar.loadingText = '没有更多了...';
									}else{
										_this.tabBar.loadingText = '';
									}
								}else {
									_this.tabBar.loadingText = '加载更多';
								}
								for (let i = 0; i < resjson.data.length; i++) {
									let item = {
										InsurePurchaseDate:resjson.data[i].VerifyDate,
										CustomerTelephone:resjson.data[i].CustomerTelephone,
										VehicleVIN:resjson.data[i].VehicleVIN,
										VehicleType:resjson.data[i].VehicleType, 
										InsureCompany:'',
                                        InsureCompanyLogo:resjson.data[i].InsureCompanyLogo,    // 保险公司logo
										InsureMoney:resjson.data[i].InsureMoney,
										VehiclePlateNo:resjson.data[i].VehiclePlateNo,
										CustomerName:resjson.data[i].CustomerName,
                                        LDate:resjson.data[i].LDate.split(' ')[0],
										type:'',
                                        CallComments:'',
										status:resjson.data[i].FlowStatus,
										SN:resjson.data[i].SN
									}
									if (resjson.data[i].InsureBizCompany) {
										item.InsureCompany = resjson.data[i].InsureBizCompany;
									}else if(resjson.data[i].InsureTrafficCompany) {
										item.InsureCompany = resjson.data[i].InsureTrafficCompany;
									}
									if (resjson.data[i].InsureTypeGroupCategory) {
										item.type = resjson.data[i].InsureTypeGroupCategory;
									}else {
										item.type = '自定义';
									}
                                    if (status === '待修改') {
                                    	item.CallComments = resjson.data[i].CallComments;
                                    }
                                    if (status === '算价') {
                                    	item.tabName = '算价';
                                        item.QueryPriceDate = resjson.data[i].QueryPriceDate;
                                    }
                                    
									_this.InsurePolicy.push(item);
									_this.linkSearchs.push(item);
								}
							}else {
								if (_this.InsurePolicy.length < 1) {
									if (status === '算价') {
										_this.isPriceShow = true;
									}else if (status === '核保中') {
										_this.isUnderwritShow = true;
									}else if (status === '待修改') {
										_this.isModifyShow = true;
									}else if (status === '待支付') {
										_this.isPaymentShow = true;
									}
								}
							}
						}
                        if (resjson.state === 'end') {
                            uni.hideLoading();
                            // 处理下拉刷新初始化
                            clearInterval(time);
                            _this.groupTop = 0;
                            _this.groupTop1 = -50;
                            _this.refreshText = '下拉刷新';
                        }
						
						
						
					},
					Scope: this
				})
			},
			zcQueryInsurePolicy4SalesMan(type) {
				_this.$ZcPublic.Server.Post({
					IsNeedLogin: true,
					Paras: {
						Name: 'uni_Insure_Detail',
						Action: 'Ext_QueryInsurePolicy4SalesMan',
						Data: {
							data: _this.searchText,
							RowCount:_this.pages,
							StartRow:_this.pageIndex
						}
					},
					Callback:function(resjson,scope) {
						if (resjson.state === 'back') {
							if (!resjson.success) {
								uni.showModal({
									title:'温馨提示',
									showCancel:false,
									content:''+resjson.msg
								})
								return;
							}
							if (type == 'init') {
							    uni.createSelectorQuery().select('#scroll5').boundingClientRect(function (res) {
							        console.log('初始化',res.top);
							        scrollToplength = res.top;
							    }).exec();
							}
                            _this.searchText = '';
							if (resjson.data.length > 0) {
								_this.completes = resjson.data;
								
								_this.pageIndex = _this.pageIndex + resjson.data.length;	// 初始化 下次加载开始下标
								_this.dataLength = resjson.data.length;
								if (_this.dataLength < _this.pages) {
									if (_this.pageIndex >= _this.pages) {
										_this.tabBar.loadingText = '没有更多了...';
									}else{
										_this.tabBar.loadingText = '';
									}
								}else {
									_this.tabBar.loadingText = '加载更多...';
								}
								
								// _this.InsurePolicy = [];
								for (let i = 0; i < resjson.data.length; i++) {
									let item = {
										InsurePurchaseDate:resjson.data[i].InsurePurchaseDate,
										CustomerTelephone:resjson.data[i].CustomerTelephone,
										VehicleVIN:resjson.data[i].VehicleVIN,
										VehicleType:resjson.data[i].VehicleType, 
										InsureCompany:resjson.data[i].InsureCompany,
                                        InsureCompanyLogo:resjson.data[i].InsureCompanyLogo,    // 保险公司logo
										InsureMoney:resjson.data[i].InsureMoney,
										VehiclePlateNo:resjson.data[i].VehiclePlateNo,
										InsureSubmitDate:resjson.data[i].InsureSubmitDate,
										CustomerName:resjson.data[i].CustomerName,
										type:'',
										status:'已完成',
										SN:resjson.data[i].SN
									}
									
									if (resjson.data[i].InsureTypeCategory) {
										item.type = resjson.data[i].InsureTypeCategory;
									}else {
										item.type = '自定义';
									}
									_this.InsurePolicy.push(item);
								}
							}else {
								_this.isCompleteShow = true;
							}
							
						}
                        if (resjson.state === 'end') {
                            uni.hideLoading();
                            // 处理下拉刷新初始化
                            clearInterval(time);
                            _this.groupTop = 0;
                            _this.groupTop1 = -50;
                            _this.refreshText = '下拉刷新';
                        }
                        
					},
					Scope: this
				})
			},
			//  订单--算价  获取算价验证码
			zcGetInsureOrderVerifyURL(item) {
                uni.showLoading({
                    title: '加载中',
                    mask: true
                });
				_this.$ZcPublic.Server.Post({
					IsNeedLogin: true,
					Paras: {
						Name: 'uni_Insure_Detail',
						Action: 'Ext_GetInsureOrderVerifyURL',
						Data: {
							SN:item.SN
						}
					},
					Callback:function(resjson,scope) {
						if (resjson.state === 'back') {
                            console.log('算价验证码 -- ',resjson);
                            if (!resjson.success) {
                            	uni.showModal({
                            		title:'温馨提示',
                            		showCancel:false,
                            		content:''+resjson.msg
                            	})
                            	return;
                            }
                            
                            _this.verifyBox.trafficUrl = 'data:image/png;base64,' + resjson.data.TrafficVerifyURL.replace(/[\r\n]/g, '');
                            _this.verifyBox.bizUrl = 'data:image/png;base64,' + resjson.data.BizVerifyURL.replace(/[\r\n]/g, '');
                            
                            _this.verifyBox.isShow = true;
                        }
				        if (resjson.state === 'end') {
				            uni.hideLoading();
				        }
				        
					},
					Scope: this
				})
			},
            //  监听 算价验证码 输入框事件
            zcVerifyInputChange(id,res) {
                if (id == 1) {
                    _this.verifyBox.trafficValue = res.detail.value;
                }else if (id == 2) {
                    _this.verifyBox.bizValue = res.detail.value;
                }
            },
            //  订单算价  -- 算价验证码 提交 or 取消
            InsureVerifyFn(type) {
                if (type == 'confirm') {
                    if (_this.verifyBox.trafficUrl) {
                        if (!_this.verifyBox.trafficValue) {
                            uni.showModal({
                                title: '温馨提示',
                                content: '尊敬的用户，请输入交强险验证码！',
                                showCancel: false,
                            });
                            return
                        }
                    }
                    if (_this.verifyBox.bizUrl) {
                        if (!_this.verifyBox.bizValue) {
                            uni.showModal({
                                title: '温馨提示',
                                content: '尊敬的用户，请输入商业险验证码！',
                                showCancel: false,
                            });
                            return
                        }
                    }
                    
                    _this.$ZcPublic.Server.Post({
                    	IsNeedLogin: true,
                    	Paras: {
                    		Name: 'uni_Insure_Detail',
                    		Action: 'Ext_SubmitInsureOrder4VerifyCode',
                    		Data: {
                    			SN:_this.verifyBox.data.SN,
                                VerifyTrafficCode: _this.verifyBox.trafficValue,    // 交强险验证码
                                VerifyBizCode: _this.verifyBox.bizValue    // 商业险验证码
                    		}
                    	},
                    	Callback:function(resjson,scope) {
                    		if (resjson.state === 'back') {
                                console.log('提交验证码 -- ',resjson);
                                if (!resjson.success) {
                                	uni.showModal({
                                		title:'温馨提示',
                                		showCancel:false,
                                		content:''+resjson.msg
                                	})
                                	return;
                                }
                                setTimeout(()=>{
                                    uni.showToast({
                                        title: '提交成功',
                                        success() {
                                            setTimeout(()=>{
                                                _this.verifyBox.trafficValue = '';
                                                _this.verifyBox.bizValue = '';
                                                _this.verifyBox.isShow = false;
                                                
                                                uni.showLoading({
                                                	title: '加载中',
                                                	mask: true
                                                });
                                                _this.pageIndex = 0;	// 当前数据开始数据是第几条
                                                _this.dataLength = 0;	// 当前数据返回个数
                                                _this.tabBar.loadingText = '';
                                                _this.InsurePolicy = [];
                                                _this.linkSearchs = [];
                                                _this.zcQueryInsureOrderList('算价');
                                            },1500)
                                        }
                                    });
                                },500)
                            }
                            if (resjson.state === 'end') {
                                uni.hideLoading();
                            }
                            
                    	},
                    	Scope: this
                    })
                }else if (type == 'cancel') {
                    _this.verifyBox.isShow = false;
                }
            }
			
			
			//  ---------  END ------------
		}
	}
</script>

<style>
	.zctab-bar-box{
		width: 100%;
		/* height: 940upx; */
		position: absolute;
		top: 0;
		left: 0;
		height: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;
	}
	.uni-tab-bar{
		width: 100%;
		flex: 1;
		height: 100%;
        overflow: initial;
		position: relative;
	}
	.zc-tab-bar{
		overflow: hidden;
		display: block;
		will-change:transform;
		transition: all 0.4S ease-in;
		width: 100%;
		height: 100%;
		position: absolute;
	}
	.zcswiper-list-box{
		height: 100%;
		background-color: #FFFFFF!important;
		display: flex;
		flex-direction: column;
		flex: 1;
		flex-shrink: 0;
		padding: 0 16upx;
	}
	.zc-swiper-tab{background-color: #3CA4FA;border-radius: 0!important;margin-bottom: 0!important;}
	.swiper-tab-list{color: #FFFFFF!important;margin: 6upx 2%;padding: 0!important;width: 16%!important;box-sizing: border-box;border: none;}
	.active{font-size: 32upx!important;border-bottom: 2upx solid #FFFFFF;}
	/* .uni-tab-bar .list{padding-bottom: 20upx!important;box-sizing: border-box;} */
	
	/* 搜索栏样式 */
    .zcSearch{display: flex;background-color: #e2e2e2;width: 100%;}
	.input-view {
		/* width: 92%; */
		display: flex;
		background-color: #FFFFFF;
		height: 72upx;
		border-radius: 10upx;
		/* overflow: hidden; */
		/* padding: 0 4%; */
		flex-wrap: nowrap;
		margin: 24upx;
		line-height: 72upx;
		flex: 1;
		padding-right: 16upx;
	}
	
	.input-view .uni-icon {
		line-height: 30px !important;
		padding: 0 10upx;
		display: flex;
		align-items: center;
		justify-content: center;
		height: 100%;
	}
	
	.input-view .input {
		height: 72upx;
		line-height: 72upx;
		padding: 0 3%;
		margin-right: 30upx;
		flex: 1;
	}
	
	.zcModel-card{margin-bottom: 20upx;padding: 20upx 0!important;background-color: #FFFFFF;}
	.zcModel-card-item{padding: 10upx 20upx;box-sizing: border-box;}
	.zcModel-card-item view{display: flex;box-sizing: border-box;line-height: 1;}
	.zcModel-card-item-text{white-space: normal;display: block;}
	/* 2019-10-28样式调整 */
	.uni-icon{
		position: absolute !important;
		right: 5upx !important;
		/* top:2upx */
		
	}
	.zc .zcModel-card:last-child{margin-bottom: 0upx!important;}
    
    /*  算价验证码弹出层样式  */
    .insureVerifyBox{position: fixed;top: 0;left: 0;width: 100%;height: 100%;display: flex;justify-content: center;align-items: center;}
    .insureVerifyMask{position: absolute;top: 0;left: 0;width: 100%;height: 100%;background-color: rgba(0,0,0,0.4);}
    .insureVerifyContent{position: absolute;width: 86%;max-width: 800upx;background-color: #FFFFFF;border-radius: 20upx;box-shadow: 0 0 16upx 0 #999999;padding: 0 20upx;}
    .insureVerifyHeader{border-bottom: 2upx solid #E5E5E5;padding: 20upx 0;}
    .insureVerifyCode{height: 100upx;margin: 0 auto;}
    .insureCompany{padding: 0 20upx;margin-left: 20upx;border-left: 2upx solid #E5E5E5;box-sizing: border-box;flex: 1;}
    .insureCompany input{width: 100%;}
    .insureVerifyCode button:last-child{background-color: #3CA4F9;color: #FFFFFF;}
    .insureVerifyCode .button-hover:last-child{opacity: 0.5;}
    /* END */
	
    /* 下拉刷新样式 */
    .refreshBox{overflow: hidden;position: absolute;bottom: 0;top: 120upx;}
    .refresh_item{display: flex;justify-content: center;align-items: center;position: absolute;width: 100%;}
    .icon-shuaxin{display: flex;align-items: center;}
    .refresh_item view:last-child{margin-left: 20upx;color: #666666;}
	/* 分页底部说明样式 */
	.uni-tab-bar-loading{text-align: center;margin: 0;}
	
	/* 无数据样式 */
	.no_model{position: relative;display: flex;flex-direction: column;align-items: center;padding: 0 160upx;padding-top: 100upx;}
	.no_text{font-size: 30upx;color: #999999;position: absolute;bottom: 28upx;}
</style>
